package com.liuzu.esys.controller;

import com.liuzu.esys.common.LayuiPageVo;
import com.liuzu.esys.common.R;
import com.liuzu.esys.pojo.Vipinform;
import com.liuzu.esys.service.VipinformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/vipinform")
public class VipinformController {
    @Autowired
    private VipinformService vipinformService;

    /**
     *查询新闻
     */
    @RequestMapping("/vipinformPageData")
    public LayuiPageVo<Vipinform> VipinformPageData(@RequestParam Map<String,Object> params){
        //测试是否可以接收到参数
       // System.out.println(params);
        return vipinformService.vipinformPageData(params);

    }

    /**
     *新闻添加操作
     */
    @GetMapping("/VipinformAdd")
    public R VipinformAdd(Vipinform vipinform){
        //查询是否可以接收到参数
        //System.out.println();
        boolean flag = vipinformService.vipinformAdd(vipinform);
        if(flag){
           return R.ok();
        }else {
            return R.error();
        }
    }
    //根据id删除
    @RequestMapping("/vipinformDel")
    public R VipinformDel(Integer id){
        //测试是否可以接收到参数
        //System.out.println(id);
        boolean flag = vipinformService.vipinformDel(id) == 1 ? true : false;
        if(flag) {
         return   R.ok();
        }else {
        return    R.error();
        }

    }




}
